<template>
    <view class="content">
        <view class="top">
            <view class="title">{{data.items}}</view>
            <view class="time">{{data.date}}</view>
        </view>
        <view class="box">
            <u-parse :html="data.record"></u-parse>
            <view class="img-box">
                <image class="img" :src="el.image" v-for="(el, ind) in data.images" :key="ind" 
                     @click="doPreview(data.images, ind)"></image>
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                id: '',
                data: {},
            };
        },
        onLoad(option) {
            this.id = option.id
            this.getData()
        },
        methods: {
            //预览照片
            doPreview(item, index) {
                let arr = []
                item.forEach(cur => {
                    arr.push(cur.image)
                })
                uni.previewImage({
                    urls: arr,
                    current: index,
                    longPressActions: {
                        success: function(data) {
                        },
                        fail: function(err) {
                        }
                    }
                });
            },
            
            getData() {
            	this.$ajax('child_record_detail', {
            		user_token: this.$getSync('userToken'),
                    id: this.id,//学习记录id
            	}).then(ret => {
            		if (ret.success == 1000) {
                        this.data = ret.detail
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    
    page{
        background-color: #fff;
        border-top: 2rpx solid #eee;
    }
    .content{
        padding: 35rpx 25rpx;
    }
    .top{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding-bottom: 35rpx;
        border-bottom: 2rpx solid #eee;
    }
    .title{
        font-size: 36rpx;
        font-weight: bold;
        padding-bottom: 10rpx;
    }
    .time{
        font-size: 24rpx;
        color: #666666;
    }
    .box{
        padding: 40rpx 0;
    }
    .img-box{
        padding-top: 30rpx;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .img{
        width: 220rpx;
        height: 220rpx;
        margin-right: 15rpx;
        margin-bottom: 15rpx;
    }
    .img:nth-child(3n) {
        margin-right: 0;
    }

</style>
